package com.mtgg.common.config;

import cn.hutool.log.Log;
import cn.hutool.log.LogFactory;
import com.mtgg.common.response.ServerResponse;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class GlobalControllerAdvice {
    private static final Log log = LogFactory.get();
    /** 处理异常 */
    @ResponseBody
    @ExceptionHandler(Exception.class)
    public Object handleException(Exception e) {
        log.error("global exception:{},{}",e.getMessage(), e.toString());
        log.error(e);
        return ServerResponse.createByErrorMessage(e.toString());
    }
}